package com.caiyi.financial.nirvana.sms.querybean;

import com.github.pagehelper.Page;

import java.io.Serializable;
import java.util.Collection;
import java.util.List;

public class PageBean<T> implements Serializable{

    // 总记录数
    private long total;
    // 结果集
    private List<T> list;
    // 总页数
    private int pages;
    // 当前页的数量 <= pageSize，该属性来自ArrayList的size属性
    private int size;


    public PageBean(List<T> list) {
        if (list instanceof Page) {
            Page<T> page = (Page<T>) list;
            this.pages = page.getPages();
            this.list = page;
            this.size = page.size();
            this.total = page.getTotal();
        } else if (list instanceof Collection) {
            this.pages = 1;
            this.list = list;
            this.size = list.size();
            this.total = list.size();
        }
    }

    public long getTotal() {
        return total;
    }

    public void setTotal(long total) {
        this.total = total;
    }

    public List<T> getList() {
        return list;
    }

    public void setList(List<T> list) {
        this.list = list;
    }

    public int getPages() {
        return pages;
    }

    public void setPages(int pages) {
        this.pages = pages;
    }

    public int getSize() {
        return size;
    }

    public void setSize(int size) {
        this.size = size;
    }
}
